package cn.wolfcode.cloud.shop.mapper;

import cn.wolfcode.cloud.shop.domain.SeckillGood;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Administrator
 */
@Mapper
public interface SeckillGoodMapper {

    @Select("select * from t_seckill_goods")
    List<SeckillGood> selectAll();

    @Select("select * from t_seckill_goods where id =#{id}")
    SeckillGood selectById(@Param("id") Long id);

    @Update("update t_seckill_goods set stock_count = stock_count - 1 where id=#{id} and stock_count > 0")
    int decrStockCount(Long id);

    @Update("update t_seckill_goods set stock_count = stock_count + 1 where id=#{id}")
    int incrStockCount(Long id);
}
